<script setup lang="ts">

import DiaryCard from "./DiaryCard.vue";
import UserProfileCard from "@/views/homeLayout/home/UserProfileCard.vue";

const total = ref(2)
const diaryList = ref([
  {
    artId: '1',
    publishTime: '2025年05月29日',
    artTitle: '花粥小记',
    artCoverUrl: 'https://cdn.seovx.com/ha/?mom=302',
    commentCount: 0,
    likeCount: 0,
  },
  {
    artId: '2',
    publishTime: '2025年05月29日',
    artTitle: '花粥小记2',
    artCoverUrl: 'https://cdn.seovx.com/ha/?mom=302',
    commentCount: 0,
    likeCount: 0,
  }
])

</script>

<template>
  <div class="app-container diary-container">
<!--    <div class="diary-grid">-->
<!--      <template v-for="diary in diaryList" key="id">-->
<!--        <DiaryCard class="diary-card" :article="diary"/>-->
<!--      </template>-->
<!--    </div>-->

    <div class="home-content">
      <div class="recently-published-articles">
        <div class="card">
          <div class="card-title">
            <span> <SvgIcon icon-class="blog-recently"></SvgIcon>&nbsp;最新文章</span>
            <div class="card-title-action">

            </div>
          </div>

          <template v-if="total <= 0">
            <el-empty style="margin: 60px auto"></el-empty>
          </template>
          <div v-else class="card-content">
            <template v-for="item in diaryList" :key="index">
              <DiaryCard :article="item"></DiaryCard>
            </template>
          </div>
          <div class="card-footer">
            <span v-if="total <= diaryList.length">~没有更多了~</span>
            <span v-else >点击加载更多</span>
          </div>
        </div>
      </div>
      <!-- 展示自己的资料卡片 -->
      <div class="profile-cards">
        <UserProfileCard class="box-shadow-card"></UserProfileCard>
      </div>
    </div>
  </div>
</template>

<style scoped lang="scss">
.diary-grid {
  display: flex;
  flex-wrap: wrap;
  .diary-card {
    display: inline-block;
    width: 260px;
    margin: 8px;
  }
}

.diary-container {
  margin: 60px auto;
  //width: 800px;
}



/* 首页的样式 */
.home-content {
  /*左右分布*/
  display: flex;
  justify-content: space-between;
  margin: 36px auto;
  max-width: 1160px;

  .recently-published-articles {
    width: 75%;
    margin-right: 16px;

    .recently-published-article {
      height: 260px;
    }
  }

  .profile-cards {
    width: 25%;

    .profile-cards-item {
      height: 300px;
    }
  }

  @media screen and (max-width: 870px) {
    .recently-published-articles {
      width: 100%;
      margin: 0 16px;
    }
    .profile-cards {
      display: none;
    }
  }


  .card {
    display: flex;
    flex-direction: column;
    margin-bottom: 20px;

    .card-title {
      display: flex;
      justify-content: space-between;
      align-items: center;
      border-bottom: 1px dashed $blog-primary-light-1;
    }

    .card-content {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      grid-gap: 16px;
      margin-top: 18px;
      padding-bottom: 36px;
      position: relative;
    }
  }
}

.card-footer {
  width: 100%;
  text-align: center;
  font-size: 12px;
  font-weight: bold;
}
</style>
